#include "GUIDemoMainLoop.h"

GUIDemoMainLoop::GUIDemoMainLoop(WiiCIS::Wiimote * WM) : wm(WM) {
}

void GUIDemoMainLoop::run() {
    bool ReadyToUse = false;
    while (1) {
        if (!wm->isConnected()) {
            wm->Connect();
        } else {
            if (!ReadyToUse) {
                wm->setRumble(true);
                wm->setLEDs(WiiCIS::WM_LED_1);
                wm->setRumble(false);
                ReadyToUse = true;
            }
            wm->Update();
            WiiCIS::WiimoteState wms = wm->getState();
            if (wms.StateChanged) {
                emit setButtons(wms.Buttons);
            }
        }
    }
}
